-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Gmail action: 'Archive Email' #16276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request introduces a new module, Changes
Sequence Diagram(s)sequenceDiagram
participant A as Archive Email Action
participant G as Gmail API
A->>G: run() calls updateLabels(message, [INBOX_LABEL_ID])
G-->>A: Returns response
A->>A: Generates archive summary message
Assessment against linked issues
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/gmail/actions/archive-email/archive-email.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/gmail/common/constants.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
components/gmail/common/constants.mjs (1)
8-8: Constant addition is correct and well-implemented.Adding the
INBOX_LABEL_IDconstant is appropriate for this feature. The value "INBOX" is the correct system label ID according to Gmail API specifications.If there are plans to use more Gmail system labels in the future (like SENT, TRASH, etc.), consider creating a structured
SYSTEM_LABEL_IDSobject instead of individual constants.-const INBOX_LABEL_ID = "INBOX"; +const SYSTEM_LABEL_IDS = { + INBOX: "INBOX", + // Other system labels can be added here in the future +}; export default { USER_ID, BODY_TYPES, HISTORICAL_EVENTS, DEFAULT_LIMIT, - INBOX_LABEL_ID, + SYSTEM_LABEL_IDS, };Also applies to: 15-15
components/gmail/actions/archive-email/archive-email.mjs (1)
6-7: Consider enhancing the description to clarify archiving behavior.The current description is accurate but could be more informative about what "archiving" means in Gmail.
- name: "Archive Email", - description: "Archive an email message. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)", + name: "Archive Email", + description: "Archive an email message by removing the INBOX label while preserving all other labels. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
components/gmail/actions/archive-email/archive-email.mjs(1 hunks)components/gmail/common/constants.mjs(1 hunks)components/gmail/package.json(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
- GitHub Check: pnpm publish
🔇 Additional comments (2)
components/gmail/package.json (1)
3-3: Version bump is appropriate for the feature addition.The increment from 0.2.10 to 0.3.0 follows semantic versioning conventions, with a minor version increase indicating the addition of a new backward-compatible feature.
components/gmail/actions/archive-email/archive-email.mjs (1)
4-18: Component metadata and props look good.The component is well-defined with appropriate key, name, description, version, and props. The naming convention follows the pattern of other Gmail actions.
| async run({ $ }) { | ||
| const { | ||
| gmail, | ||
| message, | ||
| } = this; | ||
|
|
||
| const response = await gmail.updateLabels({ | ||
| message, | ||
| removeLabelIds: [ | ||
| constants.INBOX_LABEL_ID, | ||
| ], | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully archived email (ID: ${message})`); | ||
| return response; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Implementation is correct but consider adding error handling.
The implementation correctly uses the Gmail API to remove the INBOX label, effectively archiving the email.
Consider adding error handling to provide better feedback to users:
async run({ $ }) {
const {
gmail,
message,
} = this;
- const response = await gmail.updateLabels({
- message,
- removeLabelIds: [
- constants.INBOX_LABEL_ID,
- ],
- });
-
- $.export("$summary", `Successfully archived email (ID: ${message})`);
- return response;
+ try {
+ const response = await gmail.updateLabels({
+ message,
+ removeLabelIds: [
+ constants.INBOX_LABEL_ID,
+ ],
+ });
+
+ $.export("$summary", `Successfully archived email (ID: ${message})`);
+ return response;
+ } catch (error) {
+ $.export("$summary", `Failed to archive email: ${error.message}`);
+ throw error;
+ }
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async run({ $ }) { | |
| const { | |
| gmail, | |
| message, | |
| } = this; | |
| const response = await gmail.updateLabels({ | |
| message, | |
| removeLabelIds: [ | |
| constants.INBOX_LABEL_ID, | |
| ], | |
| }); | |
| $.export("$summary", `Successfully archived email (ID: ${message})`); | |
| return response; | |
| }, | |
| async run({ $ }) { | |
| const { | |
| gmail, | |
| message, | |
| } = this; | |
| try { | |
| const response = await gmail.updateLabels({ | |
| message, | |
| removeLabelIds: [ | |
| constants.INBOX_LABEL_ID, | |
| ], | |
| }); | |
| $.export("$summary", `Successfully archived email (ID: ${message})`); | |
| return response; | |
| } catch (error) { | |
| $.export("$summary", `Failed to archive email: ${error.message}`); | |
| throw error; | |
| } | |
| }, |
luancazarine
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @GTFalcao, LGTM! Ready for QA!
Closes #16235
Since this is a new action that doesn't affect any existing components, I'm not bumping any component versions, only the
package.jsonversionSummary by CodeRabbit
New Features
Chores